package util;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class DB {

    static String JDBC_DRIVER_NAME;
    static String DB_URL;
    static String USER_ID;
    static String USER_PASSWORD;

    static {
        try {
            Properties properties = new Properties();
            InputStream inputstream = DB.class.getClassLoader().getResourceAsStream("DB.properties");
            properties.load(inputstream);
            JDBC_DRIVER_NAME = properties.getProperty("JDBC_DRIVER_NAME");
            DB_URL = properties.getProperty("DB_URL");
            USER_ID = properties.getProperty("USER_ID");
            USER_PASSWORD = properties.getProperty("USER_PASSWORD");
        } catch (Exception e) {
        }
    }

    public static Connection getConnection() throws Exception {
        Class.forName(JDBC_DRIVER_NAME);
        return DriverManager.getConnection(DB_URL, USER_ID, USER_PASSWORD);
    }

}
